home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group94a.txt
/
000129_icon-group-sender _Sat May 14 07:45:39 1994.msg
< prev
next >
Wrap
Internet Message Format
|
1994-08-19
|
7KB
Received: by cheltenham.cs.arizona.edu; Sat, 14 May 1994 10:06:26 MST
Date: Sat, 14 May 1994 07:45:39 -0600 (CST)
From: Chris Tenaglia - 257-8765 <TENAGLIA@MIS.MCW.EDU>
Subject: X-icon for Friday 13
To: icon-group@cs.arizona.edu
Message-Id: <01HCBLC3VIUQ8WWR6B@mis.mcw.edu>
Organization: Medical College of Wisconsin (Milwaukee, WI)
X-Vms-To: IN%"icon-group@cs.arizona.edu"
Mime-Version: 1.0
Content-Type: TEXT/PLAIN; CHARSET=US-ASCII
Content-Transfer-Encoding: 7BIT
Status: R
Errors-To: icon-group-errors@cs.arizona.edu
For Friday the 13th I'd like to post a little something for those
with a little bit of superstition. This is a biorythm plotter.
I thought it was a good excersize for X programming. I may not
have a full understanding of the cycles but basically it it plots
out 3 sine waves given a birthdate and year. It's not bulletproof
but it does multiple windows, and even has a different mouse
cursor for each window. This was written in Icon V8.10 and tested
on VAX/VMS 5.5 and Ultrix unix 4.3. It isn't the best sample of
Icon programming practice (I like global variables), but maybe it'll
spurr some ideas. Enjoy!
(I'm sending to the list too since I'm not sure if the postnews was working)
#
# file : bior.icn
# desc : for those with biorythm superstition
#
# update by what
# 12-may-1994 tenaglia initial write
#
global xw1,xw2, # display windows
Birth_Date, # birth date
Plot_Year, # month to plot
age # days old
#
# main line procedure
#
procedure main()
get_birth_date_and_plot_month()
draw_picture()
end
#
# draw the graph and plot the waveforms
#
procedure draw_picture()
names := ["JANUARY","FEBRUARY","MARCH","APRIL","MAY","JUNE",
"JULY","AUGUST","SEPTEMBER","OCTOBER","NOVEMBER","DECEMBER"]
shifts := [0,31,60,91,121,152,182,213,244,274,305,335]
pi := 3.1415927
pi2 := pi*2.0
sumcolor := "pink"
(xw2 := open("BIOR " || Plot_Year || " VIA " || Birth_Date,"x",
"bg=black","fg=white",
"geometry=1098x200+50+500")) |
{
write("Can't open window. Press <RETURN>")
stop("ABEND ANOX")
}
write(xw1,"")
XAttrib(xw2,"pointer=heart")
XAttrib(xw1,"fg=red")
write(xw1," PHYSIO")
XAttrib(xw1,"fg=green")
write(xw1," EMOTA")
XAttrib(xw1,"fg=yellow")
write(xw1," INTELLA")
XAttrib(xw1,"fg=" || sumcolor)
write(xw1," SUMUM")
XAttrib(xw1,"fg=white")
XSync(xw1)
XDrawLine(xw2,0,100,1098,100)
every n := 2 to *shifts do
{
disp := shifts[n]*3
XDrawLine(xw2,disp,0,disp,200)
}
a := 1
every n := 5 to 1095 by 91 do
{
XDrawString(xw2,n,10,names[a])
a +:= 1
}
every begin := !shifts do
{
every base := 5 to 25 by 5 do
{
disp := begin * 3 + base * 3
XDrawLine(xw2,disp,95,disp,105)
}
}
oldx := 0
x := 0
magn := 34
oldyp := sin((age%23)*pi2/23)*magn + 200
oldye := sin((age%28)*pi2/28)*magn + 200
oldyi := sin((age%33)*pi2/33)*magn + 200
oldyy :=(sin((age%23)*pi2/23) +
sin((age%28)*pi2/28) +
sin((age%33)*pi2/33))*magn + 100
every point := age to age + 365 do
{
yp := sin((point%23)*pi2/23)*magn + 100
ye := sin((point%28)*pi2/28)*magn + 100
yi := sin((point%33)*pi2/33)*magn + 100
yy :=(sin((point%23)*pi2/23) +
sin((point%28)*pi2/28) +
sin((point%33)*pi2/33))*magn + 100
XAttrib(xw2,"fg=red")
XDrawSegment(xw2,oldx,oldyp,x,yp)
XAttrib(xw2,"fg=green")
XDrawSegment(xw2,oldx,oldye,x,ye)
XAttrib(xw2,"fg=yellow")
XDrawSegment(xw2,oldx,oldyi,x,yi)
XAttrib(xw2,"fg=" || sumcolor)
XDrawSegment(xw2,oldx,oldyy,x,yy)
XSync(xw2)
oldyp := yp
oldye := ye
oldyi := yi
oldyy := yy
oldx := x
x +:= 3
}
XAttrib(xw2,"fg=white")
write("Click the Button!")
press := open("Respond Please","x",
"geometry=200x50+500+350","fg=black","bg=green")
XAttrib(press,"pointer=leftbutton")
XDrawString(press,20,30,"Click Me to finish ")
XEvent(press)
close(press)
close(xw1)
close(xw2)
end
#
# obtain starting information
#
procedure get_birth_date_and_plot_month()
(xw1 := open("BIOR","x",
"bg=black","fg=white",
"lines=12","columns=40")) |
{
write("Can't open window. Press <RETURN>")
stop("#1 ABEND ANOX")
}
XAttrib(xw1,"pointer=exchange")
XGotoRC(xw1,1,1)
write(xw1,"Enter Dates")
XGotoRC(xw1,3,1)
write(xw1,"BirthDate MM/DD/YYYY:")
XGotoRC(xw1,5,1)
write(xw1," Year to plot YYYY:")
XAttrib(xw1,"cursor=on")
XGotoRC(xw1,3,23)
Birth_Date := read(xw1)
XGotoRC(xw1,5,23)
Plot_Year := read(xw1)
base1 := 0
d1 := julian(Birth_Date)
d2 := julian("01/01/" || Plot_Year)
age:= d2 - d1
end
#
# parse a string into a list with respect to a delimiter
#
procedure parse(line,delims)
static chars
chars := &cset -- delims
tokens := []
line ? while tab(upto(chars)) do put(tokens,tab(many(chars)))
return tokens
end
#
# this procedure finds the julian number of a day given MM/DD/YYYY
#
procedure julian(date)
static months,shifts
initial {
months := [31,28,31,30,31,30,31,31,30,31,30,31]
shifts := [0,31,59,90,120,151,181,212,243,273,304,334]
}
part := parse(date,'-/')
(mm := integer(part[1])) | stop("julian(mm/dd/yyyy) format violation #1")
(dd := integer(part[2])) | stop("julian(mm/dd/yyyy) format violation #2")
(yyyy := integer(part[3])) | stop("julian(mm/dd/yyyy) format violation #3")
(*part = 3) | stop("julian(mm/dd/yyyy) format violation #4")
if yyyy%4 = 0 then
{
months[2] := 29
shifts := [0,31,60,91,121,152,182,213,244,274,305,335]
}
if (mm<1) | (mm>12) then stop("julian(MM/dd/yyyy) range error!")
maxd := months[mm]
if (dd<1) | (dd>maxd) then stop("julian (mm/DD/yyyy) range error!")
if yyyy < 100 then yyyy +:= 1900
if (yyyy<1901) | (yyyy>2100) then stop("julian (mm/dd/YYYY) range error!")
number := shifts[mm] + dd
every i := 1901 to yyyy do
{
yl := if (i%4)=0 then 366 else 365
number +:= yl
}
return number
end
--
Chris Tenaglia (system manager) | tenaglia@mis.mcw.edu
Medical College of Wisconsin |
8701 W. Watertown Plank Rd. | Ce que vous voyez est
Milwaukee, WI 53226 (414)257-8765 | ce que vous obtenez !